<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>ECUI 测试结果汇总</title>
    <link rel="stylesheet" type="text/css" media="screen" href="specs.css" />
    <title>Failed Cases</title>
     <style type="text/css" media="screen">
         #title a.reset {color:#FFF;float:right;margin-left:1em}
         #title a:hover, #title a:active {color:#CCC!important;}
     </style>
     <script src="USTORE.js" type="text/javascript" charset="utf-8"></script>
    <script src="http://img.baidu.com/js/tangram-1.3.2.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div class="success" id="title"><h1>ECUI Test - Failed Cases</h1>
<a href="#" class="reset" onclick="return resetUSTORE()">重置结果</a>
<a href="index.html" class="reset">返回索引页</a>
</div>
<div id="log">
    <ul class="specs" id="result_list"></ul>
</div>
<!-- 结果模版 -->
<script type="text/html" id="result_tmpl">
    <% for (var o in obj) { %>
    <% var page = jsonParse(obj[o]); %>
        <li>
            <h1><%=o%></h1>
            <ul class="specs">
                <% for (var i = 0, suite; suite = page[i++]; ) { %>
                    <li>
                        <h3><%=suite.suite%></h3>
                        <ul class="examples">
                            <% for (var j = 0, q; q = suite.cases[j++]; ) { %>
                                <li><h4><%=q%></h4></li>        
                            <% } %>
                        </ul>
                    </li>
                <% } %>
            </ul>
        </li>
    <% } %>
</script>
<script type="text/javascript" charset="utf-8">
// Simple JavaScript Templating
// John Resig - http://ejohn.org/ - MIT Licensed
(function(){
  var cache = {};
 
  this.tmpl = function tmpl(str, data){
    // Figure out if we're getting a template, or if we need to
    // load the template - and be sure to cache the result.
    var fn = !/\W/.test(str) ?
      cache[str] = cache[str] ||
        tmpl(document.getElementById(str).innerHTML) :
     
      // Generate a reusable function that will serve as a template
      // generator (and which will be cached).
      new Function("obj",
        "var p=[],print=function(){p.push.apply(p,arguments);};" +
       
        // Introduce the data as local variables using with(){}
        "with(obj){p.push('" +
       
        // Convert the template into pure JavaScript
        str
          .replace(/[\r\t\n]/g, " ")
          .split("<%").join("\t")
          .replace(/((^|%>)[^\t]*)'/g, "$1\r")
          .replace(/\t=(.*?)%>/g, "',$1,'")
          .split("\t").join("');")
          .split("%>").join("p.push('")
          .split("\r").join("\\'")
      + "');}return p.join('');");
   
    // Provide some basic currying to the user
    return data ? fn( data ) : fn;
  };
})();

// 模板解析
USTORE.init();
var STORAGE_KEY = 'ecui_test_failed_cases';
var jsonParse = baidu.json.parse;
var result_list = document.getElementById('result_list');
var storedfailedCases = jsonParse(USTORE.getValue(STORAGE_KEY) || '{}');
result_list.innerHTML = tmpl('result_tmpl', storedfailedCases);

// 重置本地储存
function resetUSTORE () {
    if (confirm('确认清空测试结果吗?')) {
        USTORE.deleteValue(STORAGE_KEY);
        location.reload(true);
    }
    return false;
}
</script>
</body>
</html>

